% change 

name  = {'Charles','Fred','Martin','Ram','Selina',... % 1st experiment
    'lily','po','ryan','vic'}; 

index = 2%length(name) % 5
    
    % get human data, with breaking pts for each step
    humanData = getData(name{1,index});
    
    %     sum_weight  = sum_weight+humanData.weight; % for average weight
    % breaking pts for each step
    StartPt = humanData.sns_brk(2);
    EndPt = humanData.sns_brk(3);
    
    % position
    if index <= exp1st
        [xpos,ypos,zpos] = getPosCartesian(humanData); % subjects from experiment 1st
    else
        [xpos,ypos,zpos] = getPosCartesianNew3D(humanData); % subjects from experiment 2st
    end
    %
for i = 1:length(xpos.hip_avg)
     model_torso(i,:) = Data2Model(xpos.torso(i),ypos.torso(i),zpos.torso(i));
     model_hip_avg(i,:) = Data2Model(xpos.hip_avg(i),ypos.hip_avg(i),zpos.hip_avg(i));
     model_lhip(i,:) = Data2Model(xpos.lhip(i),ypos.lhip(i),zpos.lhip(i));
     model_lankle(i,:) = Data2Model(xpos.lankle_avg(i), ypos.lankle_avg(i), zpos.lankle_avg(i));
     model_rhip(i,:) = Data2Model(xpos.rhip(i),ypos.rhip(i),zpos.rhip(i));
     model_rankle(i,:) = Data2Model(xpos.rankle_avg(i), ypos.rankle_avg(i), zpos.rankle_avg(i));
end
%
sleg = line([0 0],[0 0],'Color','r');
nsleg = line([0 0],[0 0],'Color','b');
hip = line([0 0],[0 0],'Color','m');
torso = line([0 0],[0 0],'Color','g');
for k = StartPt:EndPt
    axis equal;
    if ismember(index,rIndex)
    set(sleg, 'XData', [model_lankle(k,2) model_lhip(k,2)], 'YData', [model_lankle(k,3) model_lhip(k,3)], ...
            'erasemode', 'normal');
    set(nsleg, 'XData', [model_rankle(k,2) model_rhip(k,2)], 'YData', [model_rankle(k,3) model_rhip(k,3)], ...
            'erasemode', 'normal');
%         model_rankle(k,1)
    else
            set(nsleg, 'XData', [model_lankle(k,2) model_lhip(k,2)], 'YData', [model_lankle(k,3) model_lhip(k,3)], ...
            'erasemode', 'normal');
    set(sleg, 'XData', [model_rankle(k,2) model_rhip(k,2)], 'YData', [model_rankle(k,3) model_rhip(k,3)], ...
            'erasemode', 'normal');
%         model_lankle(k,1)
    end
        set(hip, 'XData', [model_rhip(k,2) model_lhip(k,2)], 'YData', [model_rhip(k,3) model_lhip(k,3)], ...
            'erasemode', 'normal');
       set(torso, 'XData', [model_torso(k,2) model_hip_avg(k,2)], 'YData', [model_torso(k,3) model_hip_avg(k,3)], ...
            'erasemode', 'normal');
        
 
    drawnow;
%     pause(0.02)
end
%%
for k = StartPt:EndPt
    axis equal;
    line([model_lhip(k,2) model_rhip(k,2)],[model_lhip(k,3) model_rhip(k,3)])
    drawnow;
    pause(0.2)
end

%%
plot3((StartPt:EndPt),model_lhip(StartPt:EndPt,2),model_lhip(StartPt:EndPt,3))
hold on;
plot3((StartPt:EndPt),model_rhip(StartPt:EndPt,2),model_rhip(StartPt:EndPt,3),'r')
%%
plot(model_hip_avg(StartPt:EndPt,2),model_hip_avg(StartPt:EndPt,3))
hold on; 
plot(model_torso(StartPt:EndPt,2),model_torso(StartPt:EndPt,3),'r')


plot((StartPt:EndPt),model_hip_avg(StartPt:EndPt,2),'m')

plot(model_hip_avg(StartPt:EndPt,2),model_hip_avg(StartPt:EndPt,3))
plot(model_hip_avg(StartPt:EndPt,2),model_hip_avg(StartPt:EndPt,3))